<template>
    <a-drawer
      :maskClosable="false"
      :title="title"
      width="70vw"
      placement="right"
      :closable="false"
      @close="close"
      :visible="visible">
      <taskProgressReportNodeForm ref="realForm" @ok="submitCallback" @close="closeAndFetch" :disabled="disableSubmit" normal></taskProgressReportNodeForm>
      <div class="drawer-footer">
        <a-popconfirm title="确定关闭弹窗吗?" @confirm="handleCancel" :getPopupContainer="(node) => node.parentNode">
          <a-button style="margin-bottom: 0;">关闭</a-button>
        </a-popconfirm>
  
        <a-popconfirm title="是否确认提交?" v-if="!disableSubmit" @confirm="handleOk" :getPopupContainer="(node) => node.parentNode">
          <a-button type="primary" style="margin-bottom: 0;">全部完成</a-button>
        </a-popconfirm>
  
      </div>
    </a-drawer>
  </template>
  
  <script>
  
    import taskProgressReportNodeForm from './taskProgressReportNodeForm'
  
    export default {
      name: 'taskProgressReportNodeModal',
      components: {
        taskProgressReportNodeForm
      },
      data () {
        return {
          title: '操作',
          visible: false,
          disableSubmit: false
        }
      },
      methods: {
        add () {
          this.visible = true
          this.$nextTick(() => {
            this.$refs.realForm.add();
          })
        },
        edit (record) {
          this.visible = true
          this.$nextTick(() => {
            this.$refs.realForm.edit(record);
          });
        },
        close () {
          this.$emit('close');
          this.visible = false;
        },
        closeAndFetch() {
          this.$emit('closeAndFetch');
          this.visible = false;
        },
        submitCallback() {
          this.$emit('ok');
          // this.visible = false;
        },
        handleOk () {
          this.$refs.realForm.submitFormAll();
        },
        handleCancel () {
          this.close()
        }
      }
    }
  </script>
  
  <style lang="less" scoped>
  /** Button按钮间距 */
    .ant-btn {
      margin-left: 30px;
      margin-bottom: 30px;
      float: right;
    }
    .drawer-footer{
      position: absolute;
      bottom: -8px;
      width: 100%;
      border-top: 1px solid #e8e8e8;
      padding: 10px 16px;
      text-align: right;
      left: 0;
      background: #fff;
      border-radius: 0 0 2px 2px;
    }
  </style>
  